Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

About Pick Objects

Picking is the process of identifying the objects in a view that are close to a specified geometric object. You might, for example, want to determine which objects in a view, if any, are sufficiently close to a particular ray. You'll use picking primarily to allow users to select objects in a view. Picking thereby provides the foundation for user interaction with three-dimensional models. You can, however, use picking for other purposes. You might, for example, use picking to determine which objects in a model are visible from a particular camera location.

Screen-space picking (or window picking ) involves testing whether the projections of three-dimensional objects onto the screen intersect or are close enough to a specified two-dimensional object on the screen.

QuickDraw 3D returns information about the picked geometric objects as they are defined in three-dimensional space. For example, you might want to know the distance of a picked object from some point. The distance reported by QuickDraw 3D is always a three-dimensional world-space distance, not a two-dimensional screen-space distance.

You perform a picking operation by creating a pick object (or, more briefly, a pick ). QuickDraw 3D provides a variety of routines that you can use to create pick objects, depending on the desired picking method. For example, you can call Q3WindowPointPick_New to create a pick object that selects objects in a view whose projections onto the screen are close enough to a particular point. The geometric object used in any picking method is the pick geometry.

To get the objects in the model that are close to the pick geometry, you must submit the entire model. The code you use to do this is similar to the rendering loop you use when drawing a model and therefore is called the picking loop. (A picking loop is a type of submitting loop.) In a picking loop, however, instead of drawing the model, you pick the model by calling routines such as Q3DisplayGroup_Submit . See Listing 5 for code that illustrates a picking loop.

Once you've completely specified the model within a picking loop, QuickDraw 3D can return to your application a list of all objects in the model that are close to the pick geometry. This list is the hit list. You can search through the returned hit list for individual items and obtain information about those items. You can also specify an order in which you want the items in the hit list to be sorted, and you can indicate in advance the kinds of objects you want QuickDraw 3D to put into the hit list. For example, you can indicate that you want QuickDraw 3D to put only entire objects into the hit list or that you want QuickDraw 3D to put only parts of objects (that is, its component vertices, edges, or faces) into the hit list.

Types of Pick Objects

Hit Identification

Hit Sorting

Hit Information


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |